<?php

namespace app\api\controller\v1;


use app\api\service\WxNotify;
use app\api\validate\IDPostiveInt;
use app\api\service\PayService;
use app\api\service\OrderService;
use think\facade\Log;
use WxPay\WxPayNotify;

class Pay extends Base
{

    public function getPreOrder($id = '')
    {
        (new IDPostiveInt)->goCheck();
        $pay = new PayService($id);
        return $pay->pay();
    }

    public function receiveNotify()
    {
        $notify = new WxPayNotify();
        $notify->Handle();
    }

    //小程序小助手支付
    public function chat_pay(){
        $post = input('post.');//过滤非验证器中的字段
        $pay = new PayService($post['order']);
        return $pay->chat_pay($post['money']);
    }

    //生成订单号
    public function order(){
        return OrderService::makeOrderNum();  //订单号
    }
}